<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>layui</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="__static/lib/layui-v2.5.5/css/layui.css" media="all">
	<link rel="stylesheet" href="__static/css/public.css" media="all">
	<style>
		.layui-form-pane .layui-form-label {
			width: 90px;
		}
		/* .layui-table-cell {
		    height: auto ;
		    white-space: normal;
		} */
	</style>
</head>
<body>
	<div class="layuimini-container">
		<div class="layuimini-main">
			<fieldset class="table-search-fieldset layuimini-container">
				<legend>搜索信息</legend>
				<form class="layui-form layui-form-pane" action="">
					<div class="layui-form-item" style="margin-bottom: 5px;">
						<div class="layui-inline">
							<label class="layui-form-label" style="width:102px">转出账户ID</label>
							<div class="layui-input-inline">
								<select name="acc_id"  lay-search="" autocomplete="off" >
									<option value="">直接选择或搜索选择</option>
									{volist name="acc_list" id='ac'}
										<option value="{$ac.id}" >{$ac.name_id}</option>
									{/volist}
						        </select>
							</div>
							<label class="layui-form-label">媒介名称</label>
							<div class="layui-input-inline">
								<select name="media_id"  lay-search="" autocomplete="off" >
									<option value="">直接选择或搜索选择</option>
									{volist name="$media_list" id='m'}
										<option value="{$m.id}" >{$m.username}</option>
									{/volist}
						        </select>
							</div>
						</div>
						<div class="layui-inline">
							<button type="button" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
						</div>
					</div>
				</form>
			</fieldset>
			<table class="layui-hide" id="accTableId" lay-filter="accTableFilter"></table> 
			<script type="text/html" id="accTableBar">
				<a style="{{d.status<2?'':'display:none;'}}" class="layui-btn layui-btn-xs  layui-btn-normal data-count-normal" lay-event="acc_save">出纳</a>
				<a style="{{d.status<2?'':'display:none;'}}" class="layui-btn layui-btn-xs  layui-btn-danger data-count-danger" lay-event="acc_edit">驳回</a>
	
			</script>
			<script type="text/html" id="acc_list">
				<span onmouseover=get_msg(this) data-msg="{{d.reject}}" style="color: red;font-weight: bold;{{d.status == 0?'':'display:none;'}}">驳回</span>
				<span  style="color: #03A9F4;font-weight: bold;{{d.status == 1?'':'display:none;'}}">审核中</span>
				<span  style="color: #4CAF50;font-weight: bold;{{d.status == 2?'':'display:none;'}}">充值成功</span>
	
			</script>
			
		</div>
	</div>
</body>
</html>
<script src="__static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="__static/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="__static/js/man.js" charset="utf-8"></script>
<script>
function get_msg(obj){
	var str = $(obj).attr('data-msg');
	layer.tips(str,$(obj));
}

//出纳确认
function acc_transfer(id){
	layer.open({
        type: 2,
        title:'出纳确认',
        area: ['60%', '60%'],
        fixed: false, //不固定
        maxmin: true,
        shadeClose:false,	//点击遮罩后关闭提示框
        scrollbar:false, //- 是否允许浏览器出现滚动
        content: "{:url('qr_transfer')}?id="+id 
    });
    //layer.full(index);
}
//驳回
function get_bohui(id){
	layer.prompt({
	  formType: 2,
	  title: '驳回原因',
	  area: ['350px', '150px'] //自定义文本域宽高
	}, function(value, index, elem){
		get_add_reject(id,value);
	});
}
//提交驳回
function get_add_reject(id,reject){
	var in2 = layer.load(1, { shade : [ 0.5, '#676a6c' ] }); 
	  $.post("{:url('transfer_reject')}?t=json",{id:id,reject:reject},function(da){
		  layer.closeAll();
		  if(da['code'] == 1){
			  //重载数据表格
			  get_apply(da['msg']);
		  }else{
			  layer.msg(da['msg'], { icon : 5 });
		  }
	  });
}

	var form,layer,element,table,$;
	layui.use([ 'form', 'table', 'layedit', 'laydate', 'element' ], function() {
		form = layui.form, layer = layui.layer, table = layui.table,$ = layui.jquery;
		pageLoading();
		table.render({
			elem: '#accTableId',
			height: 'full-150',
			id:'accReload',
			url: '{:url("list_transfer")}?t=json',
			method : 'post',
			toolbar: '#toolbar',
			loading:false,
			cols: [[
				{ field: 'id', title: '转账编号' ,width:100},
                { field: 'out_name_id', title: '转出账户ID' ,width:100},
                { field: 'out_currency', title: '转出账户币' ,width:100,style:'color: red; font-weight: bold'},
                { field: 'in_name_id', title: '转入账户ID' ,width:100},
                { field: 'in_currency', title: '转入账户币' ,width:100,style:'color: #ffb800; font-weight: bold'},
				{ field: 'rebate', title: '客户返点(%)' ,width:120},
				{ field: 'channel_rebate', title: '端口返点(%)' ,width:120},
				{ field: 'channel_name', title: '端口' ,width:120},
			    { field: 'status', title: '状态' ,templet:'#acc_list',width:100},
                { field: 'transfer_url', title: '转账凭证',width:120,templet:function(d){
					return d.transfer_url?'<img src='+d.transfer_url+'>':''
                }},
                { field: 'transfer_url', title: '财务凭证',width:120,templet:function(d){
					return d.audit_url?'<img src='+d.audit_url+'>':''
				}},
                { field: 'note', title: '备注',width:200},
				{ field: 'media_name', title: '媒介' ,width:180},
				{ field: 'create_time', title: '转账日期',width:180},
				{ title: '操作',fixed: 'right', toolbar: '#accTableBar', align: "center" ,width:130}
			]],
			limit: 30,
			page: true,
			skin: 'line',
			done: function () {
                // 添加分页加载动画的函数    
                $('.layui-laypage > a').each(function(){
                    $(this).attr('onclick',"pageLoading(this)");
                })
                layer.close(loadingIndex);
            }
		});
		
		//搜索
		form.on('submit(data-search-btn)', function(data){
			var articleFrom = data.field;
		
			table.reload('accReload', {
			  	url: '{:url("list_transfer", ["t"=>"json"])}',
				where:articleFrom
			});
			return false;
		  });
		
		//监听操作栏
		table.on('tool(accTableFilter)', function (obj) {
			var data = obj.data;
			switch (obj.event) {
				case 'acc_edit': //驳回
                    get_bohui(data.id);
				break;
				case 'acc_save'://出纳确认
                    acc_transfer(data.id);
				break;
			}
			
		});
        //监听行单击事件
		table.on('row(accTableFilter)', function(obj){
			  layer.photos({
				  photos: obj.tr
				  ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
				});
			});
	});
	//重载数据表
	function get_acc(msg){
        pageLoading();
		table.reload('accReload', {
			  url: '{:url("list_transfer")}?t=json',
			});
		layer.msg(msg, {icon: 6});
	}
</script>